﻿using AnQinFrameWorkAPI.Entity.Blog.DTO.BlogMenu;
using AnQinFrameWorkAPI.Entity.Blog.View.BlogMenu;
using AnQinFrameWorkAPI.Service.Blog;
using FrameWork.Entity;
using Microsoft.AspNetCore.Mvc;

namespace AnQinFrameWorkAPI.Controllers.Blog;

/// <summary>
///     博客菜单API
/// </summary>
[Route("api/[controller]")]
[ApiController]
[ApiExplorerSettings(GroupName = "Blog")]
public class BlogMenuController : ControllerBase
{
    // 业务服务接口
    private readonly BlogMenuService _blogMenuService;

    // 构造注入
    public BlogMenuController(BlogMenuService blogMenuService)
    {
        _blogMenuService = blogMenuService;
    }

    /// <summary>
    ///     获取菜单列表
    /// </summary>
    /// <param name="searchDTO">查询条件</param>
    [ProducesResponseType(typeof(BlogMenuView), 200)]
    [HttpGet]
    public async Task<IActionResult> GetBlogMenuList([FromQuery] BlogMenuSearchDTO searchDTO)
    {
        var response = await _blogMenuService.GetBlogMenuList(searchDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     新增菜单
    /// </summary>
    /// <param name="addDTO">菜单数据</param>
    [HttpPost]
    public async Task<IActionResult> AddBlogMenu([FromBody] BlogMenuAddDTO addDTO)
    {
        var response = await _blogMenuService.AddBlogMenu(addDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     更新菜单
    /// </summary>
    /// <param name="updateDTO">菜单数据</param>
    [HttpPut]
    public async Task<IActionResult> PutBlogMenu([FromBody] BlogMenuUpdateDTO updateDTO)
    {
        var response = await _blogMenuService.PutBlogMenu(updateDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     删除菜单
    /// </summary>
    /// <param name="deleteDTO">删除参数</param>
    [HttpDelete]
    public async Task<IActionResult> DeleteBlogMenu([FromBody] SingleIdDTO deleteDTO)
    {
        var response = await _blogMenuService.DeleteBlogMenu(deleteDTO);
        return StatusCode(response.Status, response);
    }
}